// Created by wxx on 2021/10/15.
#include <iostream>
#include <vector>

using namespace std;

/**
 * 执行用时：16 ms, 在所有 C++ 提交中击败了77.62%的用户
 * 内存消耗：5.6 MB, 在所有 C++ 提交中击败了100.00%的用户
 */
class Solution {
public:

    int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int dayOfYear(string date) {
        int year = stoi(date.substr(0, 4));
        int month = stoi(date.substr(5, 2));
        int day = stoi(date.substr(8, 2));

        int res = 0;
        for (int i = 1; i <= month - 1; i++) {
            if (i == 2)
                res += days[i] + (year % 400 == 0 || year % 4 == 0 && year % 100 != 0);
            else res += days[i];
        }
        res += day;

        return res;
    }
};

int main() {

    cout << Solution().dayOfYear("2000-03-09") << endl;  // 69
    cout << Solution().dayOfYear("2009-03-09") << endl;  // 68

    return 0;
}
